﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DTOQLDV;

namespace DAOQLDV
{
    internal class DAOTuKhoaPhuong
    {
        public static bool ThemTuKhoaPhuong(DTOPhuong dtoP, DataAccess da)
        {
            bool kq = false;
            try
            {
                if (dtoP.TenPhuong.Equals(""))
                {
                    List<String> dsTuKhoa = DAOXuLi.dsTuKhoa(dtoP.TenPhuong);
                    String sql = "";
                    foreach (String tkhoa in dsTuKhoa)
                    {
                        sql = "Insert Into TuKhoaTenPhuong(TenTuKhoaPhuong, MaPhuong) Value ('" + tkhoa + "', " + dtoP.MaPhuong + ")";
                        da.ExecuteNonQuery(sql);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return kq;
        }
    }
}
